

#include "mvfs.h"
#include "kvfs.h"
#include <iostream>
#include "../hedmodel.h"
#include "../entity/solid.h"
#include "../entity/face.h"
#include "../entity/loop.h"
#include "../entity/vertex.h"
#include "../entity/halfedge.h"
#include "../entity/ipoint.h"


MVFS::MVFS( HEDModel& _model, int _s, int _f, int _v, double _x, double _y, double _z )
: m_newsolid( NULL )
, m_s( _s )
, m_f( _f )
, m_v( _v )
, m_x( _x )
, m_y( _y )
, m_z( _z )
, m_model( &_model )
{
  m_newsolid = new Solid(_model.getFirsts());
  _model.setFirsts( m_newsolid );
}




void
MVFS::execute()
{
  std::cout << "\nMVFS::execute() \n";
  Face* newface = new Face(m_newsolid);
  Loop* newloop = new Loop(newface);
  IPoint* point = new IPoint(m_x, m_y, m_z);
  Vertex* newvertex = new Vertex(point,m_newsolid);
  HalfEdge* newhe = new HalfEdge();
  m_newsolid->setSolidno(m_s);
  newface->setFaceno(m_f);
  // Original [MANT1988] code...
  //newface->setFlout( newloop );
  // Modified code...
  newface->setFlout( NULL );
  newloop->setLedg( newhe );
  newhe->setWloop(newloop);
  newhe->setNxt(newhe);
  newhe->setPrv(newhe);
  newhe->setVtx(newvertex);
  newhe->setEdg(NULL);
  newvertex->setVertexno(m_v);
  newvertex->setVedge(newhe);
}


void
MVFS::unExecute()
{
  std::cout << "\nMVFS::unExecute() TEST!\n";

  KVFS kvfs( *m_model, m_s );
  kvfs.execute();
}


